package com.chengda.dashboard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chengda.dashboard.entity.AnnouncementInfo;
import com.chengda.dashboard.mapper.AnnouncementInfoMapper;
import com.chengda.dashboard.service.AnnouncementInfoService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 公告信息服务实现类
 */
@Service
public class AnnouncementInfoServiceImpl extends ServiceImpl<AnnouncementInfoMapper, AnnouncementInfo> implements AnnouncementInfoService {

    @Override
    public List<AnnouncementInfo> getAllActiveAnnouncements() {
        QueryWrapper<AnnouncementInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", 1);
        queryWrapper.orderByDesc("priority").orderByDesc("create_time");
        return list(queryWrapper);
    }

    @Override
    public List<AnnouncementInfo> getAllAnnouncementInfo() {
        QueryWrapper<AnnouncementInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("priority").orderByDesc("create_time");
        return list(queryWrapper);
    }
}
